package org.example.ding.dto;

import java.math.BigDecimal;

/**
 * 营养进度DTO
 */
public class NutritionProgressDto {
    private BigDecimal calories;
    private BigDecimal protein;
    private BigDecimal carbs;
    private BigDecimal fat;
    
    private BigDecimal caloriesGoal;
    private BigDecimal proteinGoal;
    private BigDecimal carbsGoal;
    private BigDecimal fatGoal;
    
    // 构造函数
    public NutritionProgressDto() {}
    
    public NutritionProgressDto(BigDecimal calories, BigDecimal protein, BigDecimal carbs, BigDecimal fat,
                               BigDecimal caloriesGoal, BigDecimal proteinGoal, BigDecimal carbsGoal, BigDecimal fatGoal) {
        this.calories = calories;
        this.protein = protein;
        this.carbs = carbs;
        this.fat = fat;
        this.caloriesGoal = caloriesGoal;
        this.proteinGoal = proteinGoal;
        this.carbsGoal = carbsGoal;
        this.fatGoal = fatGoal;
    }
    
    // Getters and Setters
    public BigDecimal getCalories() {
        return calories;
    }
    
    public void setCalories(BigDecimal calories) {
        this.calories = calories;
    }
    
    public BigDecimal getProtein() {
        return protein;
    }
    
    public void setProtein(BigDecimal protein) {
        this.protein = protein;
    }
    
    public BigDecimal getCarbs() {
        return carbs;
    }
    
    public void setCarbs(BigDecimal carbs) {
        this.carbs = carbs;
    }
    
    public BigDecimal getFat() {
        return fat;
    }
    
    public void setFat(BigDecimal fat) {
        this.fat = fat;
    }
    
    public BigDecimal getCaloriesGoal() {
        return caloriesGoal;
    }
    
    public void setCaloriesGoal(BigDecimal caloriesGoal) {
        this.caloriesGoal = caloriesGoal;
    }
    
    public BigDecimal getProteinGoal() {
        return proteinGoal;
    }
    
    public void setProteinGoal(BigDecimal proteinGoal) {
        this.proteinGoal = proteinGoal;
    }
    
    public BigDecimal getCarbsGoal() {
        return carbsGoal;
    }
    
    public void setCarbsGoal(BigDecimal carbsGoal) {
        this.carbsGoal = carbsGoal;
    }
    
    public BigDecimal getFatGoal() {
        return fatGoal;
    }
    
    public void setFatGoal(BigDecimal fatGoal) {
        this.fatGoal = fatGoal;
    }
    
    // 计算进度百分比的便利方法
    public double getCaloriesProgress() {
        if (caloriesGoal == null || caloriesGoal.compareTo(BigDecimal.ZERO) == 0) return 0;
        return calories.divide(caloriesGoal, 4, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)).doubleValue();
    }
    
    public double getProteinProgress() {
        if (proteinGoal == null || proteinGoal.compareTo(BigDecimal.ZERO) == 0) return 0;
        return protein.divide(proteinGoal, 4, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)).doubleValue();
    }
    
    public double getCarbsProgress() {
        if (carbsGoal == null || carbsGoal.compareTo(BigDecimal.ZERO) == 0) return 0;
        return carbs.divide(carbsGoal, 4, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)).doubleValue();
    }
    
    public double getFatProgress() {
        if (fatGoal == null || fatGoal.compareTo(BigDecimal.ZERO) == 0) return 0;
        return fat.divide(fatGoal, 4, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)).doubleValue();
    }
}
